<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">

<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>用document.domain解决Ajax跨域</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<SCRIPT type=text/javascript>

document.domain = "javas.com";
var x ='';

function sendCheckRequest(url)

{
 if (window.XMLHttpRequest)

 {
  req = new XMLHttpRequest();

  req.onreadystatechange = processReqChange;

  req.open("GET", url, true);
 
 req.send(null);
 
}
 
else if (window.ActiveXObject)
 
{

  req = new ActiveXObject("Microsoft.XMLHTTP");
 
 if (req)
 
 {
  
 req.onreadystatechange = processReqChange;
 
  req.open("GET", url, true);
  
 req.send();
  
}
  
else
 
 alert("failed");
 
}
}
function processReqChange() {

 if (req.readyState == 4 ){
 
 if(req.status == 200){
  
 handleResult();
  
} else {
   
alert("数据传输错误，请重试！");
 
  req.abort();
  
 delete req;
   
CollectGarbage();
  }

 }
}
function handleResult(){

 x = req.responseText;
 
parent.callExecute(x);
 
}

</SCRIPT>

<SCRIPT type=text/javascript>
 document.domain = 'javas.com';
</SCRIPT>

<META content="MSHTML 6.00.2900.3243" name=GENERATOR></HEAD>
<BODY></BODY></HTML>
